﻿@model DatabaseEntities
@{
    Account user = ViewBag.User;
    Tweet tweet = ViewBag.Tweet;

    var title = tweet.Message.FetchTitle();
    ViewBag.Title = title;

    var h1 = user.FullName.Truncate(25, false) + " on DTweet";
    var currentUser = Static.CurrentUser;
}

@section Meta
{
    <meta name="description" content="@(user.FullName)(@tweet.TweetingTime): @Html.Raw(tweet.Message.GenerateDescription())" />    
    <link rel="alternate" type="application/rss+xml" title="@user.FullName - Upcoming Tweets" href="@Url.Content("~/RSS/" + user.UniqueToken)" />    
    @if (tweet.SharedTo != "Public")
    {
        <meta name="robots" content="noindex nofollow" />
    }
}
@section H1 { @h1 }
@section UserName
{    
    @if (currentUser != null && currentUser.UniqueToken != user.UniqueToken)
    {
        <div id="you" accesskey="@currentUser.UniqueToken">@currentUser.FullName.Truncate(20)</div>
    }
    else {
        <div id="username" accesskey="@user.UniqueToken">@user.FullName.Truncate(20)</div>
    }
}

<div id="user-image" class="user-image">
    <img src="@user.Gravatar" itemprop="image" width="60" height="60" alt="" />
</div>
<div id="tweet-section" class="tweet-section">
    @*<div class="manage-tweet"></div>*@
    <h2 id="name-section" class="name-section">
        <a href="@Url.Content("~/" + user.UniqueToken)">@user.FullName</a> - <span class="time">
                                                                                 <time class="time" itemprop="date" datetime="@tweet.TweetingTime.ToMachineTime()" pubdate>@tweet.TweetingTime</time>
                                                                             </span>
    </h2>
    <div id="tweet-message" itemprop="description" class="tweet-message">
        @Html.Raw(tweet.Message.HandleAllThings())
    </div>
</div>

@section JavaScript
{
    <script src="@Url.Content("~/Content/JavaScript/JsDecoder.js")" type="text/javascript"></script>
    <script>
        var dq = dashingquill;
        dq.bind('#username', 'click', function (username) {
            location = dq.domainName + '/' + username.getAttribute('accesskey');
        });
        dq.each(dq.find('pre'), function (code) {
            var jsDecoder = new JsDecoder();
            jsDecoder.s = code.textContent;
            code.innerHTML = jsDecoder.decode();
        });

        var you = dq.find('#you');
        if (you) {
            dq.bind(you, 'click', function () {
                location = dq.domainName + '/' + you.getAttribute('accesskey');
            });
        }
    </script>
}